package com.chuanke.ckfamily.service.base;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.chuanke.ckfamily.dao.social.model.Family;
import com.chuanke.ckfamily.service.constant.Constant;
import com.chuanke.ckfamily.service.exception.CFException;

public class FamilyValidator {
	
	private static final Logger log = LoggerFactory.getLogger(FamilyValidator.class);
	
	/**
	 * 家族名称长度
	 */
	public static final int familyName_length = 10;
	/**
	 * 家族名称长度
	 */
	public static final int familyAnnouncement_length = 500;
	/**
	 * 备注名称长度
	 */
	public static final int remarkName_length = 15;

	/**
	 * @param family
	 * @param tid
	 * @return
	 * @throws CFException
	 */
	public static boolean validateFamilyTid(Family family, String tid) throws CFException {
		
		if(family==null){
			throw new CFException(FailCode.FAMILY_NOT_EXIST);
		}
		if(tid!=null && !"".equals(tid)){
			if(tid.equals(family.getTid())){
				return true;
			}
			log.error("validateFamilyTid==============>tid={}",tid);
			throw new CFException(FailCode.FAMILY_TID_MATCH);
		}
		return true;
	}

}
